import httpServe from '@/global-services/index';
type TsObj = Record<string, any>;

/** 通用api */
export const commonApi = {
	uploadFileNomal: (data: any): any => httpServe.postHttp('/base/upload/nomal')(data) // 文件上传(小文件300M以内)
};

/** 盒子管理 **/
export const BoxManageApi = {
	/* 主页面 */
	queryStatusList: (): any => httpServe.getHttp('/base/box/statusList')(),
	queryCardList: (data: any): any => httpServe.getHttp('/base/box/list')(data), // 卡片页查询
	list: (data: any): any => httpServe.getTableHttp('/base/box/page')(data), // 分页查询
	delete: (data: Array<string | number>): any => httpServe.deleteHttp('/base/box/removeByIds')(data), // 删除
	boxRestart: (data: any): any => httpServe.putHttp(`/base/box/boxRestart?boxSerial=${data}`)(), // 根据ID重启盒子
	/* 报警配置 */
	getByBoxSerial: (boxSerial: string): any => httpServe.getHttp(`/base/mHardwareAlarmConf/getByBoxSerial/${boxSerial}`)(), // 根据盒子序列号单个查询
	saveOrUpdateBatch: (data: any): any => httpServe.postHttp('/base/mHardwareAlarmConf/saveOrUpdateBatch')(data), // 批量新增/修改(删除)
	getBoxHardwareConf: (): any => httpServe.getHttp('/base/mHardwareAlarmConf/getBoxHardwareConf')(), // 获取报警配置盒子列表
	manualSynBoxData: (): any => httpServe.postHttp('/base/manualSynBoxData')(), // 数据同步
	/* 基本信息 */
	detailGetById: (id: any): any => httpServe.getHttp(`/base/box/getById/${id}`)(), // 盒子详情——根据ID查询
	updateBoxName: (data: any): any => httpServe.putHttp('/base/box/updateBoxName')(data), // 根据ID修改名称
	updateBoxTime: (data: any): any => httpServe.putHttp('/base/box/updateBoxTime')(data), // 根据ID修改系统时间
	networkGetByBoxSerial: (data: any): any => httpServe.getHttp(`/base/netConfig/getByBoxSerial/V2?boxSerial=${data.boxSerial}`)(), // 查询网络配置
	getNetworkList: (): any => httpServe.getHttp('/base/netConfig/getNetwork')(), // 获取网卡列表
	saveBoxNetConfigService: (data: any): any => httpServe.putHttp('/base/boxNetConfigService/update/V2')(data), // 保存网络配置
	getBoxSipInfo: (boxSerial: string): any => httpServe.getHttp(`/base/netConfig/getBoxSipInfo?boxSerial=${boxSerial}`)(), // 获取盒子SIP信息
	// getBoxPerformanceMonitorData: (boxSerial: string): any =>
	//   httpServe.getHttp(`/base/boxDetail/getBoxPerformanceMonitorData?boxSerial=${boxSerial}`)(), // 性能监控
	getBoxPerformanceMonitorData: (boxSerial: string): any => httpServe.getHttp(`/base/box/boxMetrics?boxSerial=${boxSerial}`)(), // 性能监控

	/* AI配置 */
	queryAiSrvList: (boxSerial: any): any =>
		httpServe.getHttp(`/base/mBoxAiService/list?boxSerial=${boxSerial}`)(
			{},
			{
				headers: {
					'hide-message': true
				}
			}
		), // 获取AI算法列表
	quereyAiSrvConfigInfo: (data: any): any =>
		httpServe.getHttp(`/base/globalAiServiceDetail/quereyAiSrvConfigInfo?bAiServerId=${data.bAiServerId}&boxSerial=${data.boxSerial}`)(), // 查询AI算法单个的配置信息
	restoreAiSrvDefaultConfig: (data: any): any => httpServe.putHttp('/base/mBoxAiService/restoreDefault')(data), // 恢复默认配置
	updateAiSrvStatus: (data: any): any => httpServe.putHttp('/base/mBoxAiService/updateStatus')(data), // 更新AI服务开启/关闭状态
	updateAiSrvConfig: (data: any): any => httpServe.putHttp('/base/mBoxAiService/update')(data), // 更新AI服务配置

	/* 人脸识别 */
	faceRecognitionList: (data: any): any => httpServe.getTableHttp('/base/faceRecognition/queryPagePersonInfo')(data), // 人脸库分页查询
	faceRecognitionImgUpload: (data: any): any =>
		httpServe.postHttp('/base/faceRecognition/upload')(data, {
			headers: { 'Content-Type': 'application/form-data' }
		}), // 人脸识别算法-文件上传接口
	savePersonInfo: (data: any): any => httpServe.postHttp('/base/faceRecognition/savePersonInfo')(data), // 人脸识别算法-人脸库信息保存
	updatePersonInfo: (data: any): any => httpServe.postHttp('/base/faceRecognition/updatePersonInfo')(data), // 人脸识别算法-人脸库信息修改
	deletePersonInfo: (data: any): any =>
		httpServe.getHttp(`/base/faceRecognition/deletePersonInfoByIds?ids=${data.ids}&boxSerial=${data.boxSerial}`)(),
	getDevicesAlgorithms: (data: any): any => httpServe.getHttp('/base/bAiServiceCamera/alarmLinkageTree')(data)
};

/** 盒子版本管理 **/
export const BoxVersionManageApi = {
	list: (data: any): any => httpServe.getTableHttp('/base/boxVersion/pageQueryBoxVersion')(data), // 分页查询
	delete: (data: Array<string | number>): any => httpServe.deleteHttp('/base/boxVersion/deleteVersionPackage')(data), // 删除
	saveBoxVersionInfo: (data: any): any => httpServe.postHttp('/base/boxVersion/saveBoxVersionInfo')(data), // 新增升级包
	getPresignedObjectUrl: (data: any): any => httpServe.getHttp(`/base/getPresignedObjectUrl/${data}`)(), // 新增升级包
	getBoxUpdateLog: (data: any): any => httpServe.getTableHttp('/base/boxVersion/getBoxUpdateLog')(data), // 详情分页查询
	getAllOnlineBoxInfoList: (data: any): any => httpServe.getHttp('/base/boxDetail/getAllOnlineBoxInfoList')(data), // 选择升级设备表格
	boxUpdateVersion: (data: any): any => httpServe.postHttp('/base/boxVersion/boxUpdateVersion')(data), // 提交设备升级
	boxRestartUpdate: (id: string): any => httpServe.postHttp(`/base/boxVersion/boxRestartUpdate?id=${id}`)(), // 重新升级
	deletePackage: (data: string): any => httpServe.deleteHttp('/base/boxVersion/deletePackage')(data) // minIO删除升级包
};

/** 算法授权 */
export const AlgoAuthApi = {
	list: (data: any): any => httpServe.getTableHttp('/base/auth/page')(data), // 分页查询
	onlineAuth: (sn: any): any =>
		httpServe.postHttp(`/base/auth/online?sn=${sn}`)('', {
			headers: {
				'hide-message': true
			}
		}), // 在、离线授权
	offlineAuth: (sn: any, formData?: any, config?: any): any => httpServe.postHttp(`/base/auth/outline?sn=${sn}`)(formData, config), // 在、离线授权
	exportSn: (data: any): any => httpServe.downloadAlarmImgs('/base/auth/export')(data, { responseType: 'blob' }) // 导出SN码
};

/** 摄像头管理 **/
export const CameraManagementAPI = {
	treeData: () => httpServe.getHttp('/base/mirgic/box/monitor/getDeviceList')(), // 树
	tree: (): any => httpServe.getHttp('/base/regionLocation/queryRegion')(), // 树查询

	list: (data: any): any => httpServe.getHttp('/base/camera/queryCameraListe')(data), // 列表数据
	editGroup: (data: any): any => httpServe.putHttp('/base/regionLocation/updateRegion')(data), // 树==>编辑新增区域位置
	addGroup: (data: any): any => httpServe.postHttp('/base/regionLocation/saveRegion')(data), // 树==>新增区域位置
	deleteRegion: (data: any): any => httpServe.deleteHttp(`/base/regionLocation/deleteRegion/${data}`)(null), // 树==>删除区域位置
	regionMove: (data: any): any => httpServe.postHttp('/base/regionLocation/regionMove')(data), // 区域调动
	AIServiceList: (): any => httpServe.getHttp('/base/globalAiService/slectList')(), // AI服务数据
	DeviceAreaList: (): any => httpServe.getHttp('/base/box/list')(), // 所属盒子数据
	deleteListCamera: (data: (string | number)[]): any => httpServe.deleteHttp('/base/camera/batchDeleteCamera')(data), // 删除
	/** 摄像头管理----新增/编辑表单部分 **/
	addCamera: (data: TsObj): any => httpServe.postHttp('/base/mDevice/save')(data), // 新增摄像头
	detailCamera: (data: string | number): any => httpServe.getHttp(`/base/mDevice/${data}`)(), // 根据ID单个查询摄像头
	editCamera: (data: TsObj): any => httpServe.putHttp('/base/mDevice/update')(data), // 编辑摄像头
	getBoxSipInfo: (data: Record<string, any>): any => httpServe.getHttp('/base/netConfig/getBoxSipInfo')(data), // 获取盒子SIP信息
	boxSelectList: (): any => httpServe.getHttp('/base/box/selectList')(), // 盒子下拉框
	queryStatusList: (): any => httpServe.getHttp('/base/comprehensive/situation/getComprehensive')(), // 摄像头状态获取
	batchImportDevice: (data: any): any => httpServe.postHttp('/base/device/import')(data), // 批量添加摄像头
	downloadFailDevice: (data: any): any => httpServe.postHttp('/base/device/download')(data, { responseType: 'blob' }), // 下载绑定失败文件
	downloadAddTemplate: () => httpServe.postHttp('/base/device/download/template')({}, { responseType: 'blob' })
};

/** 报警器管理 **/
// export const AlarmDeviceManagementAPI = {
// 	treeData: () => httpServe.getHttp('/base/mirgic/box/monitor/getDeviceList')(), // 树
// 	editGroup: (data: any): any => httpServe.putHttp('/base/regionLocation/updateRegion')(data), // 树==>编辑新增区域位置
// 	addGroup: (data: any): any => httpServe.postHttp('/base/regionLocation/saveRegion')(data), // 树==>新增区域位置
// 	deleteRegion: (data: any): any => httpServe.deleteHttp(`/base/regionLocation/deleteRegion/${data}`)(null), // 树==>删除区域位置

// 	list: (data: any): any => httpServe.getHttp('/base/av/device')(data), // 列表数据
// 	deleteAlarmDevice: (data: (string | number)[]): any => httpServe.deleteHttp('/base/av/device')(data), // 删除
// 	regionMove: (data: any): any => httpServe.postHttp('/base/av/device/move')(data), // 区域调动
// 	importConfig: (data: any): any => httpServe.postHttp('/base/av/device/import')(data), // 导入声光报警器配置
// 	exportConfig: (data: any): any => httpServe.postHttp('/base/av/device/export')(data) // 导入声光报警器配置
// };

/** 报警器管理 **/
export const AlarmDeviceManagementAPI = {
	treeData: () => httpServe.getHttp('/base/av/device/getAvDeviceTree')(), // 树
	editGroup: (data: any): any => httpServe.putHttp('/base/regionLocation/updateRegion')(data), // 树==>编辑新增区域位置
	addGroup: (data: any): any => httpServe.postHttp('/base/regionLocation/saveRegion')(data), // 树==>新增区域位置
	deleteRegion: (data: any): any => httpServe.deleteHttp(`/base/regionLocation/deleteRegion/${data}`)(null), // 树==>删除区域位置

	list: (data: any): any => httpServe.getHttp('/base/av/device')(data), // 列表数据
	deleteAlarmDevice: (data: any): any => httpServe.deleteHttp('/base/av/device')(data), // 删除
	updateInfo: (data: any): any => httpServe.postHttp('/base/av/device')(data), // 更新报警器信息
	regionMove: (data: any): any => httpServe.postHttp('/base/av/device/move')(data), // 区域调动
	operateStatus: (data: any): any => httpServe.postHttp('/base/av/device/status')(data), // 批量启禁用
	importConfig: (data: any): any => httpServe.postHttp('/base/av/device/import')(data), // 导入声光报警器配置
	exportConfig: (data: any): any =>
		httpServe.postHttp('/base/av/device/export')(data, {
			responseType: 'blob'
		}), // 导出声光报警器配置
	downloadFailConfig: (data: any): any =>
		httpServe.postHttp('/base/av/device/download')(data, {
			responseType: 'blob'
		}), //下载绑定失败文件
	updateBatchAiSrvAvDeviceEnabled: (data: any): any => httpServe.postHttp('/base/av/device/updateBatchAiSrvAvDeviceEnabled')(data) //批量启停报警算法
};

/** 摄像头管理——算法配置 **/
export const AlgorithmConfigurationAPI = {
	apiScenario: (data: Record<string, any>): any => httpServe.getHttp('/base/camera/queryCameraList')(data), // 场景配置
	getDeviceArea: (data: Record<string, any>): any => httpServe.getHttp('/base/bRecognitionArea/getDeviceArea')(data), // 查询每台设备下的区域
	runGetByAreaInfo: (data: Record<string, any>): any => httpServe.getHttp('/base/device/recognition/area/queryAreaAIList')(data), // 查询每台设备下的区域AI服务信息
	runSaveAreaInfo: (data: any): any => httpServe.postHttp('/base/area')(data), // 保存区域信息
	deleteDeviceArea: (data: any): any => httpServe.deleteHttp('/base/regionLocation/deleteRegion')(data), // 删除区域
	addDeviceArea: (data: any): any => httpServe.postHttp('/base/device/recognition/area/saveArea')(data), // 新增区域
	GetByAreaInfo: (data: Record<string, any>): any => httpServe.getHttp('/base/bAiServiceCamera/queryAreaAIList')(data), // 查询识别区域的单条AI服务详情信息
	enableDisable: (data: Record<string, any>): any => httpServe.postHttp('/base/bAiServiceCamera/enableDisable')(data), // AI服务启用/禁用
	// 账号-数据权限在使用
	getDeviceList: (): any => httpServe.getHttp('/base/mirgic/box/monitor/getDeviceList')(), // 获取设备列表// 完整树
	getSrvConfigDetailInfo: (data: Record<string, any>): any =>
		httpServe.getHttp(
			`/base/bAiServiceCamera/querySrvConfigDetailInfo?boxSerial=${data.boxSerial}&deviceId=${data.deviceId}&aiSrvType=${data.aiSrvType}`
		)(), // 切换算法配置获取算法参数配置的详细信息
	saveAreaDetailInfo: (data: TsObj): any => httpServe.postHttp('/base/device/recognition/area/saveAreaDetailInfo')(data), // 切换算法配置获取算法参数配置的详细信息
	getDeviceRecognition: (data: TsObj): any => httpServe.getHttp('/base/device/recognition/area/deviceId')(data), // 获取每台设备下的区域id列表
	getAreaAIList: (data: TsObj): any => httpServe.getHttp('/base/bAiServiceCamera/queryAreaAIList')(data) // 获取AI服务列表
};

//
/** 角色类 **/
const proxyCode = '/system';
export const RoleAPI = {
	list: (data: any): any => httpServe.getTableHttp(`${proxyCode}/role`)(data), // 列表数据
	detail: (data: string | number): any => httpServe.getHttp(`${proxyCode}/role/${data}`)(), // 根据id获取详情
	add: (data: TsObj): any => httpServe.postHttp(`${proxyCode}/role`)(data), // 新增
	edit: (data: TsObj): any => httpServe.putHttp(`${proxyCode}/role`)(data), // 编辑
	delete: (data: Array<string | number>): any => httpServe.deleteHttp(`${proxyCode}/role`)(data), // 删除
	transfer: (data: TsObj): any => httpServe.putHttp(`${proxyCode}/person/changeSuperAdmin`)(data), // 转移超管账号
	search: (data: { id: string | number; select: string }): any => httpServe.getHttp(`${proxyCode}/person/selectList`)(data), // 搜索账户列表(下拉框所需)
	personList: (data: any): any => httpServe.getTableHttp(`${proxyCode}/personList`)(data) // 列表数据
};

/** 账户类 **/
const headers = { 'content-type': 'text/html;charset=UTF-8' };
export const AccountAPI = {
	list: (data: TsObj) => httpServe.getTableHttp(`${proxyCode}/person/page`)(data), // 列表数据
	detail: (data: string | number) => httpServe.getHttp(`${proxyCode}/person/${data}`)(), // 根据id获取详情
	delete: (data: (string | number)[]) => httpServe.deleteHttp(`${proxyCode}/person/delete`)(data), // 删除
	add: (data: TsObj) => httpServe.postHttp(`${proxyCode}/person/save`)(data, { headers }), // 新增
	edit: (data: TsObj) => httpServe.putHttp(`${proxyCode}/person/update`)(data, { headers }), // 编辑
	password: (data: TsObj) => httpServe.putHttp(`${proxyCode}/person/updatePassword`)(data, { headers }), // 修改密码
	/** 账户类----数据权限部分 **/
	PermissionData: (data: string | number) => httpServe.getHttp(`${proxyCode}/personOrganization/getPermissionData/${data}`)(), // 数据权限——获取人员权限
	AddPermissionData: (data: string | number) => httpServe.postHttp(`${proxyCode}/personOrganization/savePermissionData`)(data), // 数据权限——新增人员权限
	UpdatePermissionData: (data: string | number) => httpServe.putHttp(`${proxyCode}/personOrganization/update`)(data), // 数据权限——根据账号ID修改人员权限
	getAvPermissionData: (data: string | number) => httpServe.getHttp(`${proxyCode}/sysPersonnelPermission/getAvPermissionData/${data}`)(), // 数据权限——获取报警器权限
	UpdateAvDevicePermission: (data: string | number) => httpServe.putHttp(`${proxyCode}/sysPersonnelPermission/updateAvDevice`)(data) // 数据权限——根据账号ID报警器权限
};

/** 系统日志类 **/
export const SysLogsAPI = {
	list: (data: TsObj): any => httpServe.getTableHttp(`${proxyCode}/logging/page`)(data) // 列表数据
};

/** 摄像头管理——配置 **/
export const AIConfigurationAPI = {
	resetDefaultAiConfig: (data: TsObj): any => httpServe.getHttp('/base/device/ai/srv/query/default')(data), // 查询表单默认值
	getAreaAIList: (data: TsObj): any =>
		httpServe.getHttp('/base/device/ai/srv/area/detail')(data, {
			headers: {
				'hide-message': true
			}
		}), // 获取AI服务列表
	getDeviceRecognition: (data: TsObj): any => httpServe.getHttp('/base/device/recognition/area/deviceId')(data), // 获取每台设备下的算法配置
	getAreaList: (data: TsObj): any =>
		httpServe.getHttp('/base/device/ai/srv/area')(data, {
			headers: {
				'hide-message': true
			}
		}), // 获取每台设备下的区域id列表
	addArea: (data: TsObj): any => httpServe.postHttp('/base/device/ai/srv/add/area/deviceId')(data), // 新增区域
	delArea: (data: TsObj): any => httpServe.deleteHttp('/base/device/ai/srv/deleted/areaId')(data), // 删除区域
	runGetByAreaInfo: (data: Record<string, any>): any => httpServe.getHttp('/base/device/recognition/area/queryAreaAIList')(data), // 查询每台设备下的区域AI服务信息
	saveAiServiceInfo: (data: TsObj): any => httpServe.postHttp('/base/bAiServiceCamera/saveSrvConfigDetailInfo')(data), // 保存算法配置表单
	enableDisable: (data: Record<string, any>): any => httpServe.postHttp('/base/bAiServiceCamera/enableDisable')(data), // AI服务启用/禁用
	tree: (data: TsObj): any => httpServe.getHttp('/base/regionLocation/queryRegionCameraTree')(data),
	copyAllSrv: (data: TsObj): any => httpServe.postHttp('/base/device/ai/srv/copySrvConfig')(data), // 复制全部算法配置到
	getDeviceList: (data: TsObj): any =>
		httpServe.getHttp(`/base/bAiService/getDeviceList?boxSerial=${data.boxSerial}&deviceName=${data.deviceName}`)(), // 获取设备列表// 完整树
	saveAreaDetailInfo: (data: TsObj): any => httpServe.postHttp('/base/device/recognition/area/saveAreaDetailInfo')(data), // 切换算法配置获取算法参数配置的详细信息
	getSrvConfigDetailInfo: (data: Record<string, any>): any => httpServe.getHttp('/base/device/ai/srv/detail')(data), // 切换算法配置获取算法参数配置的详细信息
	addDeviceArea: (data: any): any => httpServe.postHttp('/base/device/recognition/area/saveArea')(data), // 新增区域
	deleteDeviceArea: (data: any): any => httpServe.postHttp('/base/device/recognition/area/deleteArea')(data), // 删除区域
	runSaveAreaInfo: (data: any): any => httpServe.postHttp('/base/device/ai/srv/update/areaId')(data) // 保存区域表单数据
};

// 报警通知
export const AlarmNoticeAPI = {
	list: (data: any): any => httpServe.getTableHttp('/base/mAlarmNotifyConf/page')(data), // 列表数据
	boxDeviceList: (): any => httpServe.getHttp('/base/mDevice/boxDeviceCascade')(), // 盒子/摄像头数据
	AIServiceList: (): any => httpServe.getHttp('/base/aiService/selectList')(), // AI服务数据
	updateStatus: (data: TsObj): any => httpServe.putHttp('/base/mAlarmNotifyConf/updateStatus')(data), // 禁用、启用
	noticeGetById: (id: any): any => httpServe.getHttp(`/base/mAlarmNotifyConf/${id}`)(), // 根据ID查询
	addNotice: (data: any): any => httpServe.postHttp('/base/mAlarmNotifyConf/save')(data), // 批量新增报警通知
	delete: (data: (string | number)[]): any => httpServe.deleteHttp('/base/mAlarmNotifyConf/remove')(data), // 删除
	editNotice: (data: any): any => httpServe.putHttp('/base/mAlarmNotifyConf/update')(data) // 批量修改报警通知
};

// MQTT
export const MQTTInfoAPI = {
	save: (data: TsObj): any => httpServe.postHttp('/base/mqttInfo/save')(data), // MQTT保存
	MQTTInfo: (): any => httpServe.getHttp('/base/mqttInfo/queryMqttInfo')() // MQTT查询
};

/** 盒子管理 **/
export const AddBoxManageApi = {
	searchBox: (): any => httpServe.getHttp('/base/udp/searchLanBoxs')(), // 搜索局域网内设备
	saveBatchBoxs: (data: TsObj): any => httpServe.postHttp('/base/saveBatchBoxs')(data), // MQTT保存
	saveBoxInfo: (data: TsObj): any => httpServe.postHttp('/base/box/save')(data), // MQTT保存
	insertBox: (data: TsObj): any => httpServe.getHttp('/base/batchInsertBox/insertBox')(data) // 搜索局域网内设备
};

/** 数据回流 **/
export const DataRefluxApi = {
	getDeviceList: (): any => httpServe.getHttp('/base/mirgic/box/monitor/getDeviceList')(), // 获取设备列表
	list: (data: TsObj): any => httpServe.getTableHttp('/base/mBaseVideoReflowRecord/page')(data), // 数据回流列表
	getDeviceTree: (): any => httpServe.getHttp('/base/video/reflow/get/device')(), // 获取设备树
	saveConfig: (data: TsObj): any => httpServe.postHttp('/base/video/reflow/save')(data), // 保存/修改回流配置
	configList: (data: TsObj): any => httpServe.getTableHttp('/base/video/reflow/page')(data), // 配置列表
	deleteConfig: (id: TsObj): any => httpServe.deleteHttp(`/base/video/reflow/deleted/${id}`)(), // 删除配置
	configDetail: (id: string): any => httpServe.getHttp(`/base/video/reflow/get/config/${id}`)() // 配置详情
};
// const fanqinghong = 'http://192.168.7.217:9091/g6mirgicbox-base/v1/';
// export const DataRefluxApi = {
// 	getDeviceList: (): any => httpServe.getHttp(`${fanqinghong}/mirgic/box/monitor/getDeviceList`)(), // 获取设备列表
// 	list: (data: TsObj): any => httpServe.getTableHttp(`${fanqinghong}/mBaseVideoReflowRecord/page`)(data), // 数据回流列表
// 	getDeviceTree: (): any => httpServe.getHttp(`${fanqinghong}/video/reflow/get/device`)(), // 获取设备树
// 	saveConfig: (data: TsObj): any => httpServe.postHttp(`${fanqinghong}/video/reflow/save`)(data), // 保存/修改回流配置
// 	configList: (data: TsObj): any => httpServe.getTableHttp(`${fanqinghong}/video/reflow/page`)(data), // 配置列表
// 	deleteConfig: (id: TsObj): any => httpServe.deleteHttp(`${fanqinghong}/video/reflow/deleted/${id}`)(), // 删除配置
// 	configDetail: (id: string): any => httpServe.getHttp(`${fanqinghong}/video/reflow/get/config/${id}`)() // 配置详情
// };

export const commonTaskApi = {
	// 批量导出-任务栏-列表查询
	getExportList: (data: TsObj) => httpServe.getHttp('/base/dataConvertExport/list')(data),
	//批量删除导出任务
	// deleteExport: (params: any) =>
	// 	httpServe.deleteHttp(`/base/export/deleteBatchByIds?idList=${params.idList}&pageType=${params.pageType}`)(null),
	deleteExport: (params: any) => httpServe.deleteHttp('/base/export/deleteBatchByIds')(params),
	//下载
	downloadExport: (data: TsObj) =>
		httpServe.downloadAlarmImgs('/base/export/download')(data, {
			responseType: 'blob',
			timeout: 3600000
		}),
	exportPrepare: (data: TsObj) => httpServe.postHttp('/base/export/exportPrepare')(data),
	// 通过预签名下载
	getdownloadByPreSignature: (data: TsObj) => httpServe.getHttp('/base/export/downloadByPreSignature')(data)
};

/**
 * 根据链接下载文件
 */
export const downloadFile = (url: string, fileName?: string) => {
	const a = document.createElement('a'); //创建a标签
	a.style.display = 'none';
	a.href = url; // 指定下载链接
	a.download = fileName || '下载文件.xlsx';
	a.click(); //触发下载
	URL.revokeObjectURL(a.href); //释放URL对象
};

// 数据统计
export const dataStatisticsApi = {
	// 获取人员统计数据
	getPersonCount: () => httpServe.getHttp('/base/dataStatistics/personCount')(),
	// 获取算法报警统计数据
	getAlgorithmAlarmCount: (data: TsObj): any => httpServe.postHttp('/base/dataStatistics/algorithmAlarmCount')(data),
	// 获取单位算法报警统计数据
	getUnitCount: (data: TsObj): any => httpServe.postHttp('/base/dataStatistics/chejianViolateCount')(data),
	// 获取人员报警统计数据
	getPersonViolateRegCount: (data: TsObj): any => httpServe.postHttp('/base/dataStatistics/personViolateRegCount')(data),
	// 获取车间详情
	getQueryBanzuCount: (data: TsObj): any => httpServe.getHttp('/base/dataStatistics/queryBanzuCount')(data)
};
